<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        button{
            width: 200px;
            height: 50px;
            line-height: 50px;
            font-size: 30px;
            text-align: center;
        }
        div{
            text-align: center;
        }
        div:nth-of-type(3){
            padding: 10px 100px;

        }

    </style>
</head>
<body>
    <div>
        <button id="ld1">亮度+</button><button id="ld2">亮度-</button>
    </div>
    <div>
        <button id="zh1">字号+</button><button id="zh2">字号-</button>
    </div>
    <hr>
    <div>
        <p>JavaScript最初由Netscape的Brendan Eich设计，最初将其脚本语言命名为LiveScript，后来Netscape在与Sun合作之后将其改名为JavaScript。JavaScript最初受Java启发而开始设计的，目的之一就是“看上去像Java”，因此语法上有类似之处，一些名称和命名规范也借自Java，但JavaScript的主要设计原则源自Self和Scheme。JavaScript与Java名称上的近似，是当时Netscape为了营销考虑与Sun微系统达成协议的结果。微软同时期也推出了JScript来迎战JavaScript的脚本语言。</p>
    </div>
    <script>
        var ld1 = document.getElementById("ld1")
        var ld2 = document.getElementById("ld2")
        var zh1 = document.getElementById("zh1")
        var zh2 = document.getElementById("zh2")

        var ld = 255;
        ld1.onclick = function (){
            ld += 15
            if (ld > 255) {
                ld = 255
            }
            document.body.style.background = `rgb(${ld},${ld},${ld})`
            document.body.style.color = `rgb(${255 - ld},${255 - ld},${255 - ld})`
        }
        ld2.onclick = function (){
            ld -= 15
            if (ld < 0) {
                ld = 0
            }
            document.body.style.background = `rgb(${ld},${ld},${ld})`
            document.body.style.color = `rgb(${255 - ld},${255 - ld},${255 - ld})`
        }

        var zh = 16
        zh1.onclick = function (){
            zh += 2
            if (zh > 50) {
                zh = 50
                alert("最大了")
            }
            document.body.style.fontSize = `${zh}px`
        }
        zh2.onclick = function (){
            zh -= 2
            if (zh < 10) {
                zh = 10
                alert("最小了")
            }
            document.body.style.fontSize = `${zh}px`
        }

    </script>
</body>
</html>